<template>
  <div class="community-item">
    <div class="article-item"
         v-for="item in artiList"
         :key="item.articleId"
         @click="goCommuDetail(item.articleId)">
      <!-- 标题 -->
      <h2 class="article-title">{{item.articleTitle}}</h2>
      <!-- 文字内容 -->
      <div class="article-cont">
        <div class="abstract"
             v-html="item.articleContent"></div>
        <img :src="item.articleCover"
             v-if="item.articleCover"
             alt="">
      </div>
      <div class="article-author">
        ——by<img :src="item.avatar"
             alt="">
        <span>{{item.author}}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['artiList'],
  methods: {
    // 去详情页
    goCommuDetail(articleId) {
      this.$router.push({
        path: '/commuarticle',
        query: {
          articleId
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.article-item {
  margin-top: 20px;
  margin-bottom: 10px;
  padding-bottom: 15px;
  cursor: pointer;
  border-bottom: 1px solid #ccc;
  /* 文章标题 */
  .article-title {
    margin-left: 10px;
    font-size: 16px;
    height: 22px;
    line-height: 22px;
  }
  /* 文章内容 */
  .article-cont {
    width: 100%;
    display: flex;
    box-sizing: border-box;
    /* 文字描述 */
    .abstract {
      flex: 1;
      height: 72px;
      margin: 10px 10px 5px 10px;
      font-size: 15px;
      line-height: 24px;
      letter-spacing: 1.5px;
      color: #333;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 3;
      -webkit-box-orient: vertical;
    }
    img {
      margin-left: 30px;
      width: 160px;
      height: 95px;
      border-radius: 2px;
    }
  }
  .article-author {
    margin-left: 10px;
    display: flex;
    align-items: center;
    font-size: 14px;
    img {
      width: 20px;
      margin: 0 4px 0 5px;
    }
  }
}
</style>